﻿Public Class AnalyzeAndFindChangesActivityControl

    Public Sub Start()
        SetupEvents(True)
    End Sub
    Public Sub [Stop]()
        SetupEvents(False)
    End Sub

    Private Sub SetupEvents(ByVal startListening As Boolean)
        If startListening Then
            AddHandler Engine.Manager.AnalyzeAndFindChangesActivityGUI, AddressOf EventHandler_Activity
        Else
            RemoveHandler Engine.Manager.AnalyzeAndFindChangesActivityGUI, AddressOf EventHandler_Activity
        End If
    End Sub

    Private Sub EventHandler_Activity(ByVal e As Engine.Manager.AnalyzeAndFindChangesActivityEventArgs)
        Try
            Dim strTmp As String

            strTmp = e.JobsInQueue.ToString
            If txtJobsInQueue.Text <> strTmp Then txtJobsInQueue.Text = strTmp

            strTmp = String.Empty
            If e.Job IsNot Nothing Then
                strTmp = e.Job.Name
                If txtCurrentJob.Text <> strTmp Then txtCurrentJob.Text = strTmp
                txtCurrentPath.Text = e.CurrentDirectoryPath
                txtCurrentPath.Select(strTmp.Length, 0)
                txtCurrentPath.ScrollToCaret()
                txtFilesAnalyzed.Text = e.FilesAnalyzed.ToString
                txtChangesFound.Text = e.ChangedFilesFound.ToString
            Else
                txtCurrentJob.Text = Nothing
                txtCurrentPath.Text = Nothing
                txtFilesAnalyzed.Text = Nothing
            End If
        Catch ex As Exception
            Framework.Misc.HandleException(Me.FindForm, ex)
        End Try
    End Sub

End Class
